package com.cf.config;

import com.cf.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {
    LoginInterceptor loginInterceptor;

    @Autowired
    public WebConfig(LoginInterceptor loginInterceptor){
        this.loginInterceptor = loginInterceptor;
    }
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns("/error",
                        "/",
                        "/login",
                        "/mainUI",
                        "/register",
                        "/excel",
                        "/upload",
                        "/css/**",
                        "/js/**",
                        "/images/**",
                        "/font/**",
                        "/favicon.ico",
                        "/doc/**",
                        "/download/**",
                        "/downloads",
                        "/uis/**",
                        "/cooper/**",

                        "/judge/**",
                        "/score/**",
                        "/option/**",
                        "/ground/**",
                        "/teamOrder/**",
                        "/accessExternalImage/**",
                        "/uploadImage",
                        "/news/**",
                        "/certs/search",
                        "/team/**"
                        );
    }
}
